import { commonText } from '@/utils/utils';
import SmartSearch from '@/components/smartsearch';
import { XBomSearchSchema } from '@/pages/xbommanage/SpecialOrder/Schema';
import { getSmartSearchSchema } from '../utils';
import { useMemo } from 'react';

const { customComponents } = XBomSearchSchema;

export default function SearchTable(props) {
  const { smartSearchKey, searchLoading, initParams = {}, searchSchema = {}, ...others } = props;

  const finallSearchSchema = useMemo(() => {
    return getSmartSearchSchema(searchSchema);
  }, [searchSchema]);

  return (
    <>
      <SmartSearch
        searchPanelId={smartSearchKey}
        schema={finallSearchSchema}
        loading={searchLoading}
        initParams={initParams}
        title={commonText.smartSearchTitleText}
        isCompatibilityMode
        headerProps={{
          type: 'line',
          bottomLine: false,
        }}
        style={{ padding: '0 3px' }}
        customComponents={customComponents}
        // 自动搜索
        isAutoSearch={true}
        filterAutoSearch={false}
        {...others}
      />
    </>
  );
}
